<meta charset="utf-8" />
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="ace-icon fa fa-home home-icon"></i> <a href="index">系统管理</a>
		</li>

		<li><span>日志管理</span></li>
	</ul>
	<!-- /.breadcrumb -->
</div>

<div class="page-content">
	<div class="row">
		<div class="col-xs-12">
			<div class="clearfix"></div>
			<div class="table-header">日志管理</div>
			<div>
				<div id="dynamic-table_wrapper"
					class="dataTables_wrapper form-inline no-footer">
					<div class="row">
						<div class="widget">
							<div class="widget-main">
								<form class="form-inline" id="selefrom" action="log/sele"
									method="post">
									<input type="search" style="width:120px;height:30px "
										; class="form-control input-sm" placeholder="输入查询内容"
										aria-controls="dynamic-table" name="selevalue" id="hhh1">
									<select name="seletype" aria-controls="dynamic-table"
										style="height:30px " ; class="form-control">
										<option value="operation_user">操作用户</option>
										<option value="operation_genre">操作备注</option>
									</select> 起始时间：<input type="text" onClick="WdatePicker()"
										style="width:120px;height:30px " ; class="form-control"
										name="begintime" id="qssj" /> 终止时间：<input type="text"
										onClick="WdatePicker()" style="width:120px;height:30px "
										; class="form-control" name="endtime" id="zzsj" />
									<button id="selectfromsb" style="height:30px "
										class="btn btn-info btn-sm">查询</button>
									<button id="selectfromcz" style="height:30px "
										class="btn btn-info btn-sm">重置</button>
								</form>
							</div>
						</div>
					</div>
					<table
						class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
						id="dynamic-table" role="grid"
						aria-describedby="dynamic-table_info">
						<thead>
							<tr role="row">

								<th class="hidden-480">操作用户</th>
								<th>操作项目</th>
								<th><i class="icon-time bigger-110 hidden-480"></i>操作备注</th>
								<th class="hidden-480">操作时间</th>
							</tr>
						</thead>

						<tbody id="logpage">
						</tbody>

					</table>
					<div class="row">
						<div class="col-xs-12 col-md-12">
							<div class=" pull-left">
								<label>显示<select name="dynamic-table_length"
									aria-controls="dynamic-table" class="form-control input-sm"
									id="sel"><option value="10">10</option>
										<option value="20">20</option>
										<option value="50">50</option>
										<option value="100">100</option>
								</select> 条记录</label>
							</div>

							<div class="dataTables_paginate paging_simple_numbers ">
								<ul class="pagination" id="dynamic-table_paginate111">
														</ul>
								<div class="dataTables_paginate paging_simple_numbers">
									<div class="laypage_main laypageskin_molv" id="laypage_3">
										<span class="laypage_curr" style="background-color:#2283C5">1</span><span
											class="laypage_total"><label>到第</label><input max="1"
											min="1" class="laypage_skip" type="number"><label>页</label>
											<button type="button" class="laypage_btn">
												确定
												<tton>
										</span>
									</div>
								</div>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 更改每页显示数据的数目 -->
<script type="text/javascript">
	var sel = document.getElementById("sel");
	sel.onchange = function() {
		/* alert(sel.options[sel.selectedIndex].value); */
		$.post("log/gghs", {
			"pagen" : sel.options[sel.selectedIndex].value
		}, function(data) {
			pagedemo(1);
		});
	}
</script>

<script type="text/javascript">
	pagedemo(1);
	function pagedemo(n) {

		$.post("log/pagedemo", {
			"pageNumber" : n,
			"pch" : $("#pch").val()
		}, function(data) {
			pack(data.list); //调用上面pack()方法，填充表格数据

			if (data.totalPage == 1) {
				$("#dynamic-table_paginate111").addClass("hide");
				$("#laypage_3").removeClass("hide");
			} else {
				$("#laypage_3").addClass("hide");
				$("#dynamic-table_paginate111").removeClass("hide");
				laypage({
					cont : $('#dynamic-table_paginate111'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : data.totalPage, //总页数
					skip : true, //是否开启跳页
					skin : '#2283C5',//保持ace中间的样式
					first : 1,
					last : data.totalPage, //总页数，将尾页显示为总页数
					curr : data.pageNumber,//当前页
					groups : 5, //连续显示分页数
					jump : function(obj, first) {
						if (!first) { //一定要加此判断，否则初始时会无限刷新
							pagedemo(obj.curr);
						}
					}
				});
			}

		});
	}

	function pack(data) { //填充数据
		var dataStr = "";
		$.each(data, function(i, v) {
			dataStr += packlist(v);
		});
		$("#logpage").html(dataStr);
	}

	function packlist(v) {
		var dataStr = "";
		dataStr += '<tr>';
		dataStr += '<td>' + v.operation_user + '</td>';
		dataStr += '<td>' + v.czxm + '</td>';
		dataStr += '<td>' + v.operation_genre + '</td>';
		dataStr += '<td>' + v.operation_time + '</td>';
		dataStr += '</tr>';
		return dataStr;
	};

	/* 撤销查询 */
	$("#selectfromcz").click(function() {
		document.getElementById("hhh1").value = "";
		document.getElementById("qssj").value = "";
		document.getElementById("zzsj").value = "";
		$.post("log/sele", $("#selefrom").serialize(), function(data) {
			pagedemo(1);
		})
		return false;
	});

	/* 查询 */
	$("#selectfromsb").click(function() {
		var qssj = document.getElementById("qssj").value;
		var zzsj = document.getElementById("zzsj").value;
		if ((qssj == "" && zzsj != "") || (qssj != "" && zzsj == "")) {
			errorMsg('请输入完整的起始时间和终止时间！');
			document.getElementById("qssj").value = "";
			document.getElementById("zzsj").value = "";
			return false;
		} else if (qssj != "" && zzsj != "" && qssj >= zzsj) {
			errorMsg('终止时间应大于起始时间！');
			document.getElementById("qssj").value = "";
			document.getElementById("zzsj").value = "";
			return false;
		} else {
			$.post("log/sele", $("#selefrom").serialize(), function(data) {
				pagedemo(1);
			})
			return false;
		}

	});

	//错误提示(传入错误信息)
	function errorMsg(errorInfo) {
		layer.confirm(errorInfo, {
			btn : [ '确定' ]
		//按钮
		}, function(index) {
			layer.close(index);
		});
	}
</script>
